//////////////////////////////////////////////////////////////////////////////////////////////////////////// // // //---------------------------- Ebrahim Foulaadvand, 12 July 2013 ----------------- // // // // The routine "Burgers" solves the 1D Burgrs equation using the Lax and Lax-Wendroff methods. // // Periodic boundary condition is used. The system length L is set to one. // // Initial wave shape is Gaussian pulse. // // // // // // // //////////////////////////////////////////////////////////////////////////////////////////////////////////// #include #include #include #include #include #include #include #include #include #include using namespace std; main() { double tau=0.001,h,L=1,sigma=0.05,x; int N=400,i,n,T=10000; ofstream file0 ("initial profile n=0.plt"); //output file for the profile at timestep n=0. ofstream file1 ("profile Lax n=4500.plt"); //output file for the profile at timestep n=100. ofstream file2 ("profile Lax n=5000.plt"); //output file for the profile at timestep n=500. ofstream file3 ("profile Lax n=6000.plt"); //output file for the profile at timestep n=500. ofstream file4 ("profile LW n=4500.plt"); //output file for the profile at timestep n=500. ofstream file5 ("profile LW n=5000.plt"); //output file for the profile at timestep n=500. ofstream file6 ("profile LW n=6000.plt"); //output file for the profile at timestep n=500. vector u(N+1,0),unew(N+1,0),uL(N+1,0),uLnew(N+1,0),uLW(N+1,0),uLWnew(N+1,0),J(N+1,0); // Arrays "u" and "unew" store the current and updated values // of the scaler function u(x,t) at grid points. "L" stands for Lax and "LW" stands for Lax-Wendroff. h=L/N; cout<<"h= "<